#include<string>
using namespace std;
class Solution {
public:
    string reverseWords(string s) {
        size_t left = 0;
        size_t right = 0;
        while (s.string::find(' ', right + 1) != string::npos)
        {
            if (right == 0)
            {
                right = s.string::find(' ', right + 1);
                while (left <= right)
                {
                    s[left] = s[right];
                    left++;
                    right--;
                }
            }
            else
            {
                left = right + 1;
                right = s.string::find(' ', right + 1);
                while (left <= right)
                {
                    s[left] = s[right];
                    left++;
                    right--;
                }
            }
        }
        return s;
    }
};